﻿using System;
using System.Diagnostics;
using System.DirectoryServices;

namespace uTILLIty.ADExtractor.Core.Exporters
{
	public abstract class ExporterBase<T> : ISearchResultExporter<T>
	{
		public event EventHandler<LogEventArgs> LogMessage;
		public abstract void Export(QueryInformation query, SearchResultCollection searchResults, T configuration);

		protected virtual void RaiseLogMessage(TraceEventType eventType, string message, params object[] args)
		{
			if (LogMessage == null)
				return;

			var msg = string.Format(message, args ?? new object[0]);
			RaiseLogMessage(new LogEventArgs(eventType, msg));
		}

		protected virtual void RaiseLogMessage(LogEventArgs logEventArgs)
		{
			if (LogMessage != null)
				LogMessage(this, logEventArgs);
		}
	}
}